import {
  Controller,
  Get,
  Post,
  Body,
  Query,
  Param,
  HttpCode,
  HttpStatus,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { BacklogService } from './backlog.servece';
import { BacklogListDto } from './dto/list.dto';
import { BacklogAddDto } from './dto/add.dto';

@ApiTags('待办事项')
@Controller('backlog')
export class BacklogController {
  constructor(private readonly backlogService: BacklogService) {}

  @Get('query')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '查询待办事项列表' })
  @ApiResponse({ status: HttpStatus.OK, description: '查询成功' })
  queryBacklog(@Query() query: BacklogListDto) {
    return this.backlogService.queryBacklogService(query);
  }

  @Post('insert')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '增加待办事项' })
  addBacklog(@Body() dto: BacklogAddDto) {
    return this.backlogService.addBacklogService(dto);
  }

  @Post('update')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '更新待办事项' })
  updateBacklog(@Body() DTO: any) {
    return this.backlogService.updateBacklogService(DTO.id, DTO);
  }

  @Post('complete')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '完成待办' })
  completeBacklog(@Body() DTO: any) {
    return this.backlogService.completeBacklogService(DTO.id);
  }

  @Get('accomplish')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '待办事项完成占比' })
  accomplish(@Query() query: BacklogListDto) {
    return this.backlogService.accomplishService(query);
  }

  @Get('remove')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '删除待办事项' })
  removeBacklog(@Param() id: number) {
    return this.backlogService.deleteBacklogService(id);
  }
}
